package com.file_io;

import java.io.*;

public class Picture {
    public static void main(String[] args) {
        FileInputStream fis=null;
        DataInputStream dis=null;
        FileOutputStream fos=null;
        DataOutputStream dos=null;
        try {
            fis=new FileInputStream("E:\\project-java65-parents\\homeWork\\io\\img.JPG");
            dis=new DataInputStream(fis);
            fos=new FileOutputStream("E:\\project-java65-parents\\homeWork\\io\\img_copy.JPG");
            dos=new DataOutputStream(fos);
           byte[] bt=new byte[1024];
            int len;
            while((len=dis.read(bt))!=-1){
                dos.write(bt);
                dos.flush();
            }
            System.out.println("加载成功！");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                dos.close();
                fos.close();
                dis.close();
                fis.close();
            } catch (IOException e) {
                e.printStackTrace();
            }


        }
    }
}
